package com.hkd.user_api.controller.product;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hkd.common.api.ApiResponse;
import com.hkd.product_service.api.BrandInfoService;
import com.hkd.product_service.api.ProductCategoryService;
import com.hkd.product_service.api.ProductInfoService;
import com.hkd.product_service.api.SupplierInfoService;
import com.hkd.product_service.api.dto.*;
import com.hkd.product_service.api.vo.BrandListVO;
import com.hkd.user_api.controller.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author HKD
 * @date 2022/9/17 22:46
 */
@RestController
@RequestMapping("admin/product")
@Api(tags = "商品信息")
public class ProductInfoController extends BaseController {
    @Autowired
    private BrandInfoService brandInfoService;
    @Autowired
    private ProductInfoService productInfoService;
    @Autowired
    private SupplierInfoService supplierInfoService;
    @Autowired
    private ProductCategoryService productCategoryService;

    @ApiOperation("添加商品")
    @PostMapping("insertProduct")
    public ApiResponse insertProduct(@RequestBody InsertProductDTO param) {
        return productInfoService.insertProduct(curUserId(),param);
    }

    @ApiOperation("添加品牌信息")
    @PostMapping("insertBrand")
    public ApiResponse insertBrand(@RequestBody InsertBrandDTO param){
        return brandInfoService.insertBrandDTO(curUserId(),param);
    }

    @ApiOperation("查询品牌列表")
    @PostMapping("listBrand")
    public ApiResponse<Page<BrandListVO>> listBrand(@RequestBody BrandListQueryDTO param){
        return brandInfoService.listBrand(param);
    }

    @ApiOperation("添加供应商信息")
    @PostMapping("insertSupplier")
    public ApiResponse insertSupplier(@RequestBody InsertSupplierDTO param){
        return supplierInfoService.insertSupplier(curUserId(),param);
    }
    @ApiOperation("添加商品分类信息")
    @PostMapping("insertProductCategory")
    public ApiResponse insertProductCategory(@RequestBody List<InsertProductCategoryDTO> param){
        return productCategoryService.insertProductCategory(curUserId(),param);
    }
}
